// author: Nicolas Liu
// description: Modified Booth encoder

`include "PRV564Config.v"
`include "PRV564Define.v"

module booth2(
    input wire[64:0] x, // multiplicand
    input wire[2:0] y, // multiplier
    output reg[127:0] z, // partial product
    output reg[1:0] c // carry
);
    wire[64:0] x_comp;
    assign x_comp = ~x;
    always @(*) begin
        case(y)
        3'b011: begin
            z = {{62{x[64]}}, x, 1'b0};
            c = 2'b00;
        end
        3'b100: begin
            z = {{62{x_comp[64]}}, x_comp, 1'b0};
            c = 2'b10;
        end
        3'b001, 3'b010: begin
            z = {{63{x[64]}}, x};
            c = 2'b00;
        end
        3'b101, 3'b110: begin
            z = {{63{x_comp[64]}}, x_comp};
            c = 2'b01;
        end
        default: begin
            z = 128'b0;
            c = 2'b00;
        end
        endcase
    end
endmodule

